package com.xj.exportfile.controller;

import com.xj.exportfile.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@Api(tags = "文件导出接口")
@RestController
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    private DemoService demoService;

    @PostMapping("/exportExcel")
    @ApiOperation(value = "导出 Excel", httpMethod = "POST")
    public void exportExcel(HttpServletResponse response) {
        demoService.exportExcel(response);
    }

    @PostMapping("/exportPdf")
    @ApiOperation(value = "导出 pdf", httpMethod = "POST")
    public void exportPdf(HttpServletResponse response) {
        demoService.exportPdf(response);
    }

    /**
     * 批量导出 pdf
     */
    @ApiOperation("批量导出 pdf")
    @PostMapping("/exportZip")
    public void exportZip(HttpServletResponse response) throws Exception {
        demoService.exportZip(response);
    }
}
